var PromptComponent = React.createClass({
	componentDidMount: function() {

	},
	receiveMsg: function(data) {

	},
    getInitialState: function () {
        this.props.isHidden = true;
        return this.props ? this.props : {};
    },
    close: function() {
        this.setState({
            isHidden: true
        });
        return this;
    },
    show: function() {
        var self = this;
        this.setState({
            isHidden: false
        });
        if(this.state.data.success) {
            this.state.data.success();
        }
        if(this.state.data.type == "success") {
            $(".success").animate({
                opacity: 0
            }, 3000, function () {
                $(".success").css("opacity", "1");
                self.setState({
                    isHidden: true
                });
            });
        }
    },
    render:function() {
        var data = this.state.data;
        data.style = "";
        switch(data.type) {
            case "warning": {
                data.iconStyle = "prompt-warning-icon";
                data.style = "prompt-box warning"
                break;
            }
            case "success": {
                data.iconStyle = "prompt-success-icon";
                data.style = "prompt-box success"
                break;
            }
            case "notify": {
                data.iconStyle = "prompt-notify-icon";
                data.style = "prompt-box notify"
                break;
            }
        }
        return ~prompt;
    }
});
PromptComponent.init = function(config) {
    if($("#prompt").length > 0) {
        $("#prompt").remove();
    }
    var divEle = $("<div id='prompt'>");
    var prompt = ReactDOM.render(<PromptComponent data={config} />, divEle[0]);
    $("body").append(divEle);
    return prompt;
}
module.exports = PromptComponent;